<template>
  <div class="comp">
    <div class="form form-inline form-search">
      <select class="form-control input-sm" v-model="search.questionType">
        <option value="-1">全部</option>
        <option value="2">A股</option>
        <option value="3">港股</option>
        <option value="1">组合</option>
        <option value="4">迷你组合</option>
        <option value="5">资讯</option>
        <option value="6">存股宝</option>
        <option value="0">其他</option>
      </select>
      <input type="text" class="form-control input-sm" v-model="search.keyword" placeholder="关键字">
      <button class="btn btn-sm btn-primary" @click="searchList">搜索</button>
    </div>
    <table v-show="list && list.length > 0" class="table table-bordered table-hover">
      <caption>问答库</caption>
      <thead>
        <tr>
          <th class="col-xs-1">ID</th>
          <th class="col-xs-2">问题</th>
          <th class="col-xs-1 col-nowrap">问题类别</th>
          <th class="col-xs-1 col-nowrap">回答类别</th>
          <th class="col-nowrap">回答索引</th>
          <th class="col-xs-4">回答文本</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="it in list">
          <td>{{it.id}}</td>
          <td class="text-justify">{{it.question}}</td>
          <td>{{it.questionType | AIQuestionType }}</td>
          <td>{{it.answerType | AIAnswerType}}</td>
          <td>{{it.answerId}}</td>
          <td class="text-justify">{{it.answerContent}}</td>
          <td class="col-nowrap text-right">
            <button class="btn btn-sm btn-primary" @click="updateItem(it)">编辑</button>
            <button class="btn btn-sm btn-danger" @click="deleteItem(it.id)">删除</button>
          </td>
        </tr>
      </tbody>
    </table>
    <vue-pages :pages.sync="pages" :get-list="getList"></vue-pages>
  </div>
</template>
<style src="./question-list.css" scoped></style>
<script src="./question-list.js"></script>